JournalViewModel

class JournalViewModel @Inject constructor(journalRepository: JournalRepository) : ViewModel

ViewModel responsible for handling journal entry operations and providing them to the UI.

This ViewModel interacts with the JournalRepository to manage the creation, updating, deletion, and retrieval of journal entries. It exposes a StateFlow of JournalUIState that contains the list of journal entries to be displayed in the UI.

Constructors

Link copied to clipboard
@Inject
constructor(journalRepository: JournalRepository)

Properties

Link copied to clipboard
val uiState: StateFlow<JournalUIState>

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard

Adds or updates an existing journal entry.

fun addEntry(title: String, content: String)

Adds a new journal entry with the provided title and content.

Link copied to clipboard

Deletes a journal entry by the entry object itself.

Deletes a journal entry by its ID.

Link copied to clipboard
Link copied to clipboard

Retrieves a journal entry by its ID.

Link copied to clipboard
fun updateEntry(id: String, newTitle: String, newContent: String)

Updates the title and content of an existing journal entry.